package controllers

import (
	beego "github.com/beego/beego/v2/server/web"
	"shang/conmon"
)

type SendController struct {
	beego.Controller
}

func (s *SendController) Send() {
	mobile := s.GetString("mobile")
	code, err := conmon.SendCode(mobile)
	if err != nil {
		s.Data["json"] = map[string]interface{}{
			"code": 400,
			"msg":  "短信发送失败",
			"data": "",
		}
		s.ServeJSON()
		return
	}
	//models.Redis.Set("code"+mobile, code, time.Second)
	s.Data["json"] = map[string]interface{}{
		"code": 200,
		"msg":  "短信发送成功",
		"data": code,
	}
	s.ServeJSON()
}
